import { Component, OnInit, OnDestroy } from '@angular/core';
import { WebSocketService } from 'app/ptpmc/comm/websocket-service';
import { ReportUrls } from 'app/ptpmc/comm/report.urls.conf';
import { LocalStorage } from 'app/ptpmc/localstorage/local.storage';
import { CommService } from 'app/ptpmc/comm/comm.service';
import { Router } from '@angular/router';
declare var h5_android;

@Component({
    selector: 'app-all-plane',
    templateUrl: './plane.component.html',
    styleUrls: ['./plane.component.scss']
})
export class AllPlaneComponent implements OnInit, OnDestroy {

    height;
    timeNow;

    production = [];//CSS1
    productionjjg = [];
    production2 = [];//CSS5
    production2jjg = [];
    production3 = [];//GFE2
    production3jjg = [];
    production4 = [];//GF9
    production4jjg = [];
    production5 = [];//BEV3
    production6 = [];//HEV2
    production6jjg = [];
    // phev
    production_phev = [];
    // bev
    production_bev = [];

    listNow = [];
    listNow2 = [];
    listNow3 = [];
    listNow4 = [];
    listNow4jjg = [];
    listNow5 = [];
    listNow6 = [];
    // phev
    listNow_phev = [];
    // bev
    listNow_bev = [];

    listHistory = [];
    listHistory2 = [];
    listHistory3 = [];
    listHistory4 = [];
    listHistory4jjg = [];
    listHistory5 = [];
    listHistory6 = [];
    // phev
    listHistory_phev = [];
    // bev
    listHistory_bev = [];

    audioList = [];
    alarmMessage = [];

    timeInterval;

    connStatus = false;

    constructor(private wsService: WebSocketService, private ls: LocalStorage, private commServices: CommService,private router: Router) { }

    ngOnInit() {

        this.refreshHistory();

        // this.timeInterval = setInterval(() => {
        //   this.timeNow = this.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss');
        // }, 1000);

        const timeAudioInterval = setInterval(() => {
            if (this.audioList && this.audioList.length > 0) {
                const brower = navigator.userAgent;
                const currentAudio = this.audioList.shift();
                if (brower.indexOf('Android') !== -1) {
                    h5_android.playMp3(currentAudio.value);
                } else {
                    const a = document.createElement('audio');
                    a.src = currentAudio.value;
                    // console.log(currentAudio.value)
                    a.play();
                }
            }
        }, 3000);

        setInterval(()=>{
            this.refreshHistory();
        },2000 * 60 )


        this.connWs();
        this.connWs2();
        this.connWs3();
        this.connWs4();
        this.connWs5();
        this.connWs6();
        // phev
        this.connWs_phev();
        // bev
        this.connWs_bev();

        this.commServices
        .doGetUrl(`${this.commServices.CSSUrl}/tip/filter/list/msg`)
        .subscribe(model => {
            if (model.resultCode === 200) {
                this.alarmMessage = model.data.map(e=>e.faultWordDescription);
            }
        });

    }

    back(){
        history.go(-1)
    }

    nppt(){
        var nppt = document.getElementById("nppt");
        var cppt = document.getElementById("cppt");
        nppt.style.display = "flex";
        cppt.style.display = "none";
        // nppt.style.visibility = "visible";
        // cppt.style.visibility = "collapse";
    }

    cppt(){
        var nppt = document.getElementById("nppt");
        var cppt = document.getElementById("cppt");
        nppt.style.display = "none";
        cppt.style.display = "flex";
        // nppt.style.visibility = "collapse";
        // cppt.style.visibility = "visible";
    }

    //CSS1
    connWs() {
        try {
            if (this.wsService && this.wsService.ws) { this.wsService.ws.close(); }
        } catch (e) {

        }
        //const url = ReportUrls.BaseUrl.replace('http://', '');
        const url = '10.19.9.64:8080/report';
        this.wsService.createObservableSocket(`ws://${url}/ws?uid=${this.ls.get('ptpmc_userId')}`)
            .subscribe(
                data => {
                    this.connStatus = true;
                    // console.log(data);
                    try {
                        const res = JSON.parse(data);
                        if (res.key === 'exit') {
                            // alert('当前账户在其它电脑登录！');
                        } else if (res.key === 'play_wav_plane') {
                            const wavUrl = ReportUrls.BaseUrl + res.value;
                            res.value = wavUrl;
                            this.audioList.push(res);
                        } else if (res.key === 'prodState') {
                            const value = JSON.parse(res.value);
                            this.production = [];
                            this.productionjjg = [];
                            value.forEach(item => {
                                const subArea = item.subArea;
                                //const subArea = item.subArea.substr(0,2);
                                const equipment = item.equipment;
                                const hours = item.hours;
                                const unhours = item.unhours;
                                const jph = item.jph;
                                if (subArea == 'KL' || subArea == 'BL' || subArea == 'HL'){
                                    this.productionjjg.push({ subArea: subArea, equipment: equipment, hours: hours,unhours: unhours, jph: jph });
                                }else{
                                    this.production.push({ subArea: subArea, equipment: equipment, hours: hours,unhours: unhours, jph: jph });
                                }
                            });
                        } else if (res.key === 'fault') {
                            const value = JSON.parse(res.value);
                            this.listNow = [];
                            value.forEach(item => {
                                const subArea = item.subArea;
                                const station = item.station;
                                const duration = item.duration;
                                const code = item.code;
                                const faultWordDescription = item.faultWordDescription;

                                this.listNow.push(
                                    { subArea: subArea, station: station, duration: duration, code: code, faultWordDescription: faultWordDescription }
                                );
                            
                            });

                        }
                    } catch (e) {

                    }
                },
                err => { console.log(err); },
                () => {
                    console.log('连接断开');
                    this.connStatus = false;
                }
            );
    }

    //CSS5
    connWs2() {
        try {
            if (this.wsService && this.wsService.ws2) { this.wsService.ws2.close(); }
        } catch (e) {

        }
        this.wsService.createObservableSocket2(`ws://10.19.9.64:8081/report/ws?uid=${this.ls.get('ptpmc_userId')}`)
            .subscribe(
                data => {
                    this.connStatus = true;
                    try {
                        const res = JSON.parse(data);
                        if (res.key === 'exit') {
                        } else if (res.key === 'play_wav_plane') {
                            const wavUrl = ReportUrls.BaseUrl + res.value;
                            res.value = wavUrl;
                            this.audioList.push(res);
                        } else if (res.key === 'prodState') {
                            const value = JSON.parse(res.value);
                            this.production2 = [];
                            this.production2jjg = [];
                            value.forEach(item => {
                                const subArea = item.subArea.substr(0,2);
                                const equipment = item.equipment;
                                const hours = item.hours;
                                const unhours = item.unhours;
                                const jph = item.jph;
                                if(subArea == 'BL' || subArea == 'HL' || subArea == 'KL'){
                                    this.production2jjg.push({ subArea: subArea, equipment: equipment, hours: hours,unhours: unhours, jph: jph });
                                }else{
                                    this.production2.push({ subArea: subArea, equipment: equipment, hours: hours,unhours: unhours, jph: jph });
                                }
                            });
                        } else if (res.key === 'fault') {
                            const value = JSON.parse(res.value);
                            this.listNow2 = [];
                            value.forEach(item => {
                                const subArea = item.subArea;
                                const station = item.station;
                                const duration = item.duration;
                                const code = item.code;
                                const faultWordDescription = item.faultWordDescription;

                                this.listNow2.push(
                                    { subArea: subArea, station: station, duration: duration, code: code, faultWordDescription: faultWordDescription }
                                );
                            
                            });

                        }
                    } catch (e) {

                    }
                },
                err => { console.log(err); },
                () => {
                    console.log('连接断开');
                    this.connStatus = false;
                }
            );
    }

    //GFE2
    connWs3() {
        try {
            if (this.wsService && this.wsService.ws3) { this.wsService.ws3.close(); }
        } catch (e) {

        }
        this.wsService.createObservableSocket3(`ws://10.19.9.75:8080/report/ws?uid=${this.ls.get('ptpmc_userId')}`)
            .subscribe(
                data => {
                    this.connStatus = true;
                    try {
                        const res = JSON.parse(data);
                        if (res.key === 'exit') {
                        } else if (res.key === 'play_wav_plane') {
                            const wavUrl = ReportUrls.BaseUrl + res.value;
                            res.value = wavUrl;
                            this.audioList.push(res);
                        } else if (res.key === 'prodState') {
                            const value = JSON.parse(res.value);
                            this.production3 = [];
                            this.production3jjg = [];
                            value.forEach(item => {
                                const subArea = item.subArea;
                                const equipment = item.equipment;
                                const hours = item.hours;
                                const unhours = item.unhours;
                                const jph = item.jph;
                                //if(subArea == ''){this.production3jjg.push{}}
                                if(subArea == 'CL1' || subArea == 'HL1'){
                                    this.production3jjg.push({ subArea: subArea, equipment: equipment, hours: hours,unhours: unhours, jph: jph });
                                }else{
                                    this.production3.push({ subArea: subArea, equipment: equipment, hours: hours,unhours: unhours, jph: jph });
                                }
                            });
                        } else if (res.key === 'fault') {
                            const value = JSON.parse(res.value);
                            this.listNow3 = [];
                            value.forEach(item => {
                                const subArea = item.subArea;
                                const station = item.station;
                                const duration = item.duration;
                                const code = item.code;
                                const faultWordDescription = item.faultWordDescription;

                                this.listNow3.push(
                                    { subArea: subArea, station: station, duration: duration, code: code, faultWordDescription: faultWordDescription }
                                );
                            
                            });

                        }
                    } catch (e) {

                    }
                },
                err => { console.log(err); },
                () => {
                    console.log('连接断开');
                    this.connStatus = false;
                }
            );
    }

    //GF9
    connWs4() {
        try {
            if (this.wsService && this.wsService.ws4) { this.wsService.ws4.close(); }
        } catch (e) {

        }
        //this.wsService.createObservableSocket4(`ws://localhost:8080/report/ws?uid=${this.ls.get('ptpmc_userId')}`)
        this.wsService.createObservableSocket4(`ws://10.19.9.74:8080/report/ws?uid=${this.ls.get('ptpmc_userId')}`)
            .subscribe(
                data => {
                    this.connStatus = true;
                    try {
                        const res = JSON.parse(data);
                        if (res.key === 'exit') {
                        } else if (res.key === 'play_wav_plane') {
                            const wavUrl = ReportUrls.BaseUrl + res.value;
                            res.value = wavUrl;
                            this.audioList.push(res);
                        } else if (res.key === 'prodState') {
                            const value = JSON.parse(res.value);
                            this.production4 = [];
                            this.production4jjg = [];
                            value.forEach(item => {
                                const subArea = item.subArea;
                                const equipment = item.equipment;
                                const hours = item.hours;
                                const unhours = item.unhours;
                                const jph = item.jph;
                                if (subArea == 'AL1' || subArea == 'BA1' || subArea == 'CA1' || subArea == 'HA1' || subArea == 'SA1'|| subArea == 'VA1') {
                                    this.production4.push({ subArea: subArea, equipment: equipment, hours: hours,unhours: unhours, jph: jph });
                                  }  else {
                                    this.production4jjg.push({ subArea: subArea, equipment: equipment, hours: hours,unhours: unhours, jph: jph });
                                  }
                            });
                        } else if (res.key === 'fault') {
                            const value = JSON.parse(res.value);
                            this.listNow4 = [];
                            this.listNow4jjg = [];
                            value.forEach(item => {
                                const subArea = item.subArea;
                                const station = item.station;
                                const duration = item.duration;
                                const code = item.code;
                                const faultWordDescription = item.faultWordDescription;
                                if(subArea == 'G9AL1' || subArea == 'G9BA1' || subArea == 'G9CA1' || subArea == 'G9HA1' || subArea == 'G9SA1' || subArea == 'G9VA1'){
                                    this.listNow4.push(
                                        { subArea: subArea, station: station, duration: duration, code: code, faultWordDescription: faultWordDescription }
                                    );
                                }else{
                                    this.listNow4jjg.push(
                                        { subArea: subArea, station: station, duration: duration, code: code, faultWordDescription: faultWordDescription }
                                    );
                                }
                            });

                        }
                    } catch (e) {

                    }
                },
                err => { console.log(err); },
                () => {
                    console.log('连接断开');
                    this.connStatus = false;
                }
            );
    }

    //BEV3
    connWs5() {
        try {
            if (this.wsService && this.wsService.ws5) { this.wsService.ws5.close(); }
        } catch (e) {

        }
        this.wsService.createObservableSocket5(`ws://10.19.9.74:8081/report/ws?uid=${this.ls.get('ptpmc_userId')}`)
            .subscribe(
                data => {
                    this.connStatus = true;
                    try {
                        const res = JSON.parse(data);
                        if (res.key === 'exit') {
                        } else if (res.key === 'play_wav_plane') {
                            const wavUrl = ReportUrls.BaseUrl + res.value;
                            res.value = wavUrl;
                            this.audioList.push(res);
                        } else if (res.key === 'prodState') {
                            const value = JSON.parse(res.value);
                            this.production5 = [];
                            value.forEach(item => {
                                const subArea = item.subArea;
                                const equipment = item.equipment;
                                const hours = item.hours;
                                const unhours = item.unhours;
                                const jph = item.jph;
                                this.production5.push({ subArea: subArea, equipment: equipment, hours: hours,unhours: unhours, jph: jph });

                            });
                        } else if (res.key === 'fault') {
                            const value = JSON.parse(res.value);
                            this.listNow5 = [];
                            value.forEach(item => {
                                const subArea = item.subArea;
                                const station = item.station;
                                const duration = item.duration;
                                const code = item.code;
                                const faultWordDescription = item.faultWordDescription;

                                this.listNow5.push(
                                    { subArea: subArea, station: station, duration: duration, code: code, faultWordDescription: faultWordDescription }
                                );
                            
                            });

                        }
                    } catch (e) {

                    }
                },
                err => { console.log(err); },
                () => {
                    console.log('连接断开');
                    this.connStatus = false;
                }
            );
    }

    //HEV2
    connWs6() {  
        try {
            if (this.wsService && this.wsService.ws6) { this.wsService.ws6.close(); }
        } catch (e) {

        }
        this.wsService.createObservableSocket6(`ws://10.19.9.75:8081/report/ws?uid=${this.ls.get('ptpmc_userId')}`)
            .subscribe(
                data => {
                    this.connStatus = true;
                    try {
                        const res = JSON.parse(data);
                        if (res.key === 'exit') {
                        } else if (res.key === 'play_wav_plane') {
                            const wavUrl = ReportUrls.BaseUrl + res.value;
                            res.value = wavUrl;
                            this.audioList.push(res);
                        } else if (res.key === 'prodState') {
                            const value = JSON.parse(res.value);
                            this.production6 = [];
                            this.production6jjg = [];
                            value.forEach(item => {
                                const subArea = item.subArea;
                                const equipment = item.equipment;
                                const hours = item.hours;
                                const unhours = item.unhours;
                                const jph = item.jph;
                                //if(subArea == ''){this.production6jjg.push{}}
                                this.production6.push({ subArea: subArea, equipment: equipment, hours: hours,unhours: unhours, jph: jph });
                            });
                        } else if (res.key === 'fault') {
                            const value = JSON.parse(res.value);
                            this.listNow6 = [];
                            value.forEach(item => {
                                const subArea = item.subArea;
                                const station = item.station;
                                const duration = item.duration;
                                const code = item.code;
                                const faultWordDescription = item.faultWordDescription;
                                this.listNow6.push(
                                    { subArea: subArea, station: station, duration: duration, code: code, faultWordDescription: faultWordDescription }
                                );
                            
                            });

                        }
                    } catch (e) {

                    }
                },
                err => { console.log(err); },
                () => {
                    console.log('连接断开');
                    this.connStatus = false;
                }
            );
    }
    // phev
    connWs_phev() {  
        try {
            if (this.wsService && this.wsService.ws_phev) { this.wsService.ws_phev.close(); }
        } catch (e) {

        }
        this.wsService.createObservableSocket_phev(`ws://10.19.14.6:8080/report/ws?uid=${this.ls.get('ptpmc_userId')}`)
            .subscribe(
                data => {
                    this.connStatus = true;
                    try {
                        const res = JSON.parse(data);
                        if (res.key === 'exit') {
                        } else if (res.key === 'play_wav_plane') {
                            const wavUrl = ReportUrls.BaseUrl + res.value;
                            res.value = wavUrl;
                            this.audioList.push(res);
                        } else if (res.key === 'prodState') {
                            const value = JSON.parse(res.value);
                            this.production_phev = [];
                            value.forEach(item => {
                                const subArea = item.subArea;
                                const equipment = item.equipment;
                                const hours = item.hours;
                                const unhours = item.unhours;
                                const jph = item.jph;
                                this.production_phev.push({ subArea: subArea, equipment: equipment, hours: hours,unhours: unhours, jph: jph });
                            });
                        } else if (res.key === 'fault') {
                            const value = JSON.parse(res.value);
                            this.listNow_phev = [];
                            value.forEach(item => {
                                const subArea = item.subArea;
                                const station = item.station;
                                const duration = item.duration;
                                const code = item.code;
                                const faultWordDescription = item.faultWordDescription;
                                this.listNow_phev.push(
                                    { subArea: subArea, station: station, duration: duration, code: code, faultWordDescription: faultWordDescription }
                                );
                            
                            });

                        }
                    } catch (e) {

                    }
                },
                err => { console.log(err); },
                () => {
                    console.log('连接断开');
                    this.connStatus = false;
                }
            );
    }

    // bev
    connWs_bev() {  
        try {
            if (this.wsService && this.wsService.ws_bev) { this.wsService.ws_bev.close(); }
        } catch (e) {

        }
        this.wsService.createObservableSocket_bev(`ws://10.19.14.10:8080/report/ws?uid=${this.ls.get('ptpmc_userId')}`)
            .subscribe(
                data => {
                    this.connStatus = true;
                    try {
                        const res = JSON.parse(data);
                        if (res.key === 'exit') {
                        } else if (res.key === 'play_wav_plane') {
                            const wavUrl = ReportUrls.BaseUrl + res.value;
                            res.value = wavUrl;
                            this.audioList.push(res);
                        } else if (res.key === 'prodState') {
                            const value = JSON.parse(res.value);
                            this.production_bev = [];
                            value.forEach(item => {
                                const subArea = item.subArea;
                                const equipment = item.equipment;
                                const hours = item.hours;
                                const unhours = item.unhours;
                                const jph = item.jph;
                                this.production_bev.push({ subArea: subArea, equipment: equipment, hours: hours,unhours: unhours, jph: jph });
                            });
                        } else if (res.key === 'fault') {
                            const value = JSON.parse(res.value);
                            this.listNow_bev = [];
                            value.forEach(item => {
                                const subArea = item.subArea;
                                const station = item.station;
                                const duration = item.duration;
                                const code = item.code;
                                const faultWordDescription = item.faultWordDescription;
                                this.listNow_bev.push(
                                    { subArea: subArea, station: station, duration: duration, code: code, faultWordDescription: faultWordDescription }
                                );
                            
                            });

                        }
                    } catch (e) {

                    }
                },
                err => { console.log(err); },
                () => {
                    console.log('连接断开');
                    this.connStatus = false;
                }
            );
    }

    ngOnDestroy(): void {
        if (this.timeInterval) {
            clearInterval(this.timeInterval);
        }
    }
    formatDate(date: Date, fmt) {
        const o = {
            'M+': date.getMonth() + 1, // 月份
            'd+': date.getDate(), // 日
            'h+': date.getHours(), // 小时
            'm+': date.getMinutes(), // 分
            's+': date.getSeconds(), // 秒
            'q+': Math.floor((date.getMonth() + 3) / 3), // 季度
            'S': date.getMilliseconds() // 毫秒
        };
        if (/(y+)/.test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
        };
        for (const k in o) {
            if (new RegExp('(' + k + ')').test(fmt)) {
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)));
            }
        }
        return fmt;
    }

    refreshHistory(){
        // css1
        this.commServices
            .doGetUrl('http://10.19.9.64:8080/report/tip/filter/list/current')
            .subscribe(model => {
                if (model.resultCode === 200) {
                    this.listHistory = [];
                    model.data.forEach(e => {
                        const subArea = e.subArea;
                        const duration = (Number.parseInt(e.duration) / 60).toFixed(0);
                            this.listHistory.push(
                                { subArea: subArea, station: e.station, duration: duration, shfitDay: e.startTime.split(" ")[1],faultWordDescription:e.faultWordDescription });
                    });

                }
            });
        // css5
        this.commServices
            .doGetUrl('http://10.19.9.64:8081/report/tip/filter/list/current')
            .subscribe(model => {
                if (model.resultCode === 200) {
                    this.listHistory2 = [];
                    model.data.forEach(e => {
                        const subArea = e.subArea;
                        const duration = (Number.parseInt(e.duration) / 60).toFixed(0);
                            this.listHistory2.push(
                                { subArea: subArea, station: e.station, duration: duration, shfitDay: e.startTime.split(" ")[1],faultWordDescription:e.faultWordDescription });
                    });
                }
            });
        // gfe
        this.commServices
        .doGetUrl('http://10.19.9.75:8080/report/tip/filter/list/current')
        .subscribe(model => {
            if (model.resultCode === 200) {
                this.listHistory3 = [];
                model.data.forEach(e => {
                    const subArea = e.subArea;
                    const duration = (Number.parseInt(e.duration) / 60).toFixed(0);
                        this.listHistory3.push(
                            { subArea: subArea, station: e.station, duration: duration, shfitDay: e.startTime.split(" ")[1],faultWordDescription:e.faultWordDescription });
                });
            }
        });
        // gf9
        this.commServices
            //.doGetUrl('http://localhost:8080/report/tip/filter/list/current')
            .doGetUrl('http://10.19.9.74:8080/report/tip/filter/list/current')
            .subscribe(model => {
                if (model.resultCode === 200) {
                    this.listHistory4 = [];
                    model.data.forEach(e => {
                        const subArea = e.subArea;
                        const duration = (Number.parseInt(e.duration) / 60).toFixed(0);
                        if (subArea == 'G9AL1' || subArea == 'G9BA1' || subArea == 'G9CA1' || subArea == 'G9HA1' || subArea == 'G9SA1' || subArea == 'G9VA1') {
                            this.listHistory4.push(
                                { subArea: subArea, station: e.station, duration: duration, shfitDay: e.startTime.split(" ")[1],faultWordDescription:e.faultWordDescription });
                        }else{
                            this.listHistory4jjg.push(
                                { subArea: subArea, station: e.station, duration: duration, shfitDay: e.startTime.split(" ")[1],faultWordDescription:e.faultWordDescription });
                        }
                    });
                }
            });
        // bev3
        this.commServices
            .doGetUrl('http://10.19.9.74:8081/report/tip/filter/list/current')
            .subscribe(model => {
                if (model.resultCode === 200) {
                    this.listHistory5 = [];
                    model.data.forEach(e => {
                        const subArea = e.subArea;
                        const duration = (Number.parseInt(e.duration) / 60).toFixed(0);
                            this.listHistory5.push(
                                { subArea: subArea, station: e.station, duration: duration, shfitDay: e.startTime.split(" ")[1],faultWordDescription:e.faultWordDescription });
                    });
                }
            });
        //hev2
        this.commServices
            .doGetUrl('http://10.19.9.75:8081/report/tip/filter/list/current')
            .subscribe(model => {
                if (model.resultCode === 200) {
                    this.listHistory6 = [];
                    model.data.forEach(e => {
                        const subArea = e.subArea;
                        const duration = (Number.parseInt(e.duration) / 60).toFixed(0);
                            this.listHistory6.push(
                                { subArea: subArea, station: e.station, duration: duration, shfitDay: e.startTime.split(" ")[1],faultWordDescription:e.faultWordDescription });
                    });
                }
            });
        // phev
        this.commServices
            .doGetUrl('http://10.19.14.6:8080/report/tip/filter/list/current')
            .subscribe(model => {
                if (model.resultCode === 200) {
                    this.listHistory_phev = [];
                    model.data.forEach(e => {
                        const subArea = e.subArea;
                        const duration = (Number.parseInt(e.duration) / 60).toFixed(0);
                            this.listHistory_phev.push(
                                { subArea: subArea, station: e.station, duration: duration, shfitDay: e.startTime.split(" ")[1],faultWordDescription:e.faultWordDescription });
                    });
                }
            });
        // bev
        this.commServices
            .doGetUrl('http://10.19.14.10:8080/report/tip/filter/list/current')
            .subscribe(model => {
                if (model.resultCode === 200) {
                    this.listHistory_bev = [];  
                    model.data.forEach(e => {
                        const subArea = e.subArea;
                        const duration = (Number.parseInt(e.duration) / 60).toFixed(0);
                            this.listHistory_bev.push(
                                { subArea: subArea, station: e.station, duration: duration, shfitDay: e.startTime.split(" ")[1],faultWordDescription:e.faultWordDescription });
                    });
                }   
            });
    }

}
